package array;

public class LeetCode_50 {
    public static void main(String[] args) {
        String s = "aaaaaaaaaaabc";
        System.out.println(longestPalindrome(s));
    }
    public static String longestPalindrome(String str){
        int l = 0;
        int r = 0;
        for (int i = 0; i < str.length(); i++) {
            l = i - 1;
            while (l >= 0){
                if(str.charAt(l) == str.charAt(i)){
                    l--;
                }else {
                    break;
                }
            }
        }
        return null;
    }
    public int giveGem(int[] gem, int[][] operations) {
        int operLeft = 0;
        int operRight = operations.length - 1;
        while (operLeft != operRight){
            subAdd(gem,operations,operations[operLeft][0],operations[operLeft][1]);
            subAdd(gem,operations,operations[operRight][0],operations[operRight][1]);
            operLeft--;
            operRight++;
        }
        int min = gem[0];
        int max = gem[0];
        for (int i = 1; i < gem.length; i++) {
            min = Math.min(min,gem[i]);
            max = Math.max(max,gem[i]);
        }
        return max - min;
    }
    public void subAdd(int[] gem, int[][] operations,int x,int y){
        int sub = gem[x] / 2;
        gem[x] = gem[x] - sub;
        gem[y] = gem[y] + sub;
    }
}
